package cn.jbolt.func;

import cn.jbolt.ai.resource.function.anno.FunctionResource;
import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;

import java.util.function.Consumer;

public class FunctionDemo {

    @FunctionResource(desc = "demo")
    public void sendMessage(String toUserName, String msg) {
        System.out.println("成功将消息：" + msg + "发送给" + toUserName);
    }


    @FunctionResource(desc = "根据某些关键字查询用户相关的信息，包括用户的用户名、编号、性别、年龄等信息")
    public JSONObject searchUsers(String keywords) {
        System.out.println("查询到用户成功");
        JSONObject info = new JSONObject();
        info.fluentPut("name", "张三").fluentPut("age", "20")
                .fluentPut("sex", "男")
                .fluentPut("sn", "1001");
        return info;
    }


    private void testFUnc(Consumer<String> consumer) {
        try {
            consumer.accept("hello");
        } catch (Exception e) {
            System.out.println(1);
            e.printStackTrace();
        }
    }

    @Test
    public void test2() {
        testFUnc(s -> {
            String a= null;

            System.out.println(a.length());
        });
    }

}
